﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SuperSerialization.Tree
{
    /// <summary>
    /// A node representing an object instance.
    /// </summary>
    class ObjectNode : Node
    {
        /// <summary>
        /// The type name of the object.
        /// </summary>
        public string Type = "System.Object";

        /// <summary>
        /// A list of fields of this object.
        /// </summary>
        public List<FieldNode> Members = new List<FieldNode>();

        /// <summary>
        /// Constructs a new object node.
        /// </summary>
        /// <param name="type">The type name of the object.</param>
        /// <param name="members">The list of field nodes.</param>
        public ObjectNode(string type, List<FieldNode> members)
        {
            this.Type = type;
            this.Members = members;
        }

        /// <summary>
        /// Constructs a new empty, object node with the default type of System.Object.
        /// </summary>
        public ObjectNode() { }

        public override void Accept(TreeVisitor.AbstractVisitor visitor)
        {
            visitor.VisitObject(this);
        }
    }
}
